<!DOCTYPE html>
<html>
<head>
    <title>WebSocket Test</title>
    <script type="text/javascript">
        var ws;

        function init() {
            if (window["WebSocket"]) {
                ws = new WebSocket("ws://localhost:6161/ws");
                ws.onmessage = function(event) {
                    console.log("Message from server: " + event.data);
                };
                ws.onerror = function(error) {
                    console.log("WebSocket Error: " + error);
                };
                ws.onopen = function(r) {
                    console.log("WebSocket r: " + r);
                };
            } else {
                alert("Your browser does not support WebSockets.");
            }
        }

        function send() {
            if (ws) {
                //ws.close()
                ws.send("Hello Server!");
            }
        }
    </script>
</head>
<body onload="init();">
<button onclick="send();">Send Hello Server!</button>
</body>
</html>